package com.kust.smarthome.web.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kust.smarthome.web.mapper.NoticeMapper;
import com.kust.smarthome.web.model.Notice;
import com.kust.smarthome.web.service.INoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author iAuzre
 * @since 2021-07-06
 */
@Service
public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> implements INoticeService {

    @Autowired
    private NoticeMapper noticeMapper;

    @Override
    public List<Notice> getState0ByUser(Integer userId) {
        QueryWrapper<Notice> query = new QueryWrapper<>();
        query.eq("user_id", userId)
                .eq("state", 0);
        List<Notice> list = noticeMapper.selectList(query);
        return list;
    }

    @Override
    public List<Notice> queryMessage2(Integer typeId,Integer deviceId) {
        return noticeMapper.selectMessage2(typeId,deviceId);
    }

    @Override
    public List<Notice> queryMessage1(Integer userId) {
        return noticeMapper.selectMessage1(userId);
    }

    @Override
    public void updateState(Integer userId, Integer typeId, Integer deviceId) {
        noticeMapper.updateState(userId,typeId,deviceId);
    }
}
